﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Robotics.Race
{
    public partial class frmCarConfiguration : Form
    {
        private Car car = null;
        public Car Car
        {
            get { return car; }
        }

        public frmCarConfiguration(Car car)
        {
            InitializeComponent();
			this.car = car;
			carPanel.LoadSettings( car );
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            if (!carPanel.Nxt.Brick.IsConnected)
                carPanel.Connect();
			//carPanel.SaveSettings();
            car.Name = carPanel.CarName;
            Close();
        }

        public Car SelectCar()
        {
            ShowDialog();
            return car;
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
